<?php
/**
 * Created by PhpStorm.
 * User: 王松
 * Time: 2017/7/16 13:07
 */

namespace App\Project\Printer;

use App\Models\MedicalHpi;

class HpiPrinter extends PrinterAbstract
{
    public function __construct(MedicalHpi $hpi)
    {
        $this->model = $hpi;
    }

    public function diet()
    {
        $diet = $this->model->diet;

        if (!$diet) {
            return null;
        }

        $print = [
            $this->fe('diet', 'staple', '主食', 'g'),
            $this->ft('hpi.diet', $this->fe('diet', 'meat'), '肉类'),
            $this->ft('hpi.diet', $this->fe('diet', 'fat'), '油脂'),
            $this->ft('hpi.diet', $this->fe('diet', 'vegetable'), '蔬菜'),
            $this->ft('hpi.diet', $this->fe('diet', 'fruit'), '水果'),
            $this->ft('hpi.diet', $this->fe('diet', 'salt'), '食盐'),
            $this->ft('hpi.sport', $this->fe('sport'), '患者运动'),
            $this->ft('hpi.other', $this->fe('normal', 'diet'), '食欲'),
            $this->ft('hpi.other', $this->fe('normal', 'sleep'), '睡眠'),
            $this->ft('hpi.other', $this->fe('normal', 'spirit'), '精神'),
            $this->ft('hpi.other', $this->fe('normal', 'emotion'), '情绪'),
            $this->ft('hpi.shit.value', $this->fe('normal', 'shit.value'), '大便:'),
            $this->ft('hpi.shit.frequency', $this->fe('normal', 'shit.frequency'), '每天'),
            $this->fe('normal', 'shit.remark', '备注: '),
            $this->ft('hpi.pee.frequency', $this->fe('normal', 'pee.frequency'), '小便'),
            $this->ft('hpi.pee.value', $this->fe('normal', 'pee.value'), '夜尿'),
            $this->fe('normal', 'pee.remark', '备注: '),
        ];

        return $this->getPrintStr('一般情况：', $print);
    }

    public function thyroid()
    {
        $thyroid = $this->model->thyroid;

        if (!$thyroid) {
            return null;
        }
        $print = [];
        if ($this->has($thyroid, 'started_at')) {
            $print[] = $this->fe('thyroid', 'started_at', '起病日期:');
        }

        if ($this->has($thyroid, 'inducement')) {
            $print[] = $this->ft('hpi.inducement', $this->fe('thyroid', 'inducement'), '诱因:');
        }


        if ($this->has($thyroid, 'symptoms')) {
            $print[] = '起病症状：' . implode('、', $thyroid['symptoms']);
        }
        if ($this->has($thyroid, 'symptoms_remark')) {
            $print[] = $this->fe('thyroid', 'symptoms_remark', '备注：');
        }

        if ($this->has($thyroid, 'examination')) {
            $print[] = '化验检查：' . implode('、', $thyroid['examination']);
        }
        if ($this->has($thyroid, 'examination_remark')) {
            $print[] = $this->fe('thyroid', 'examination_remark', '备注：');
        }

        if ($this->has($thyroid, 'hyperthyroidism')) {
            $print[] = '甲亢相关症状：' . implode('、', $thyroid['hyperthyroidism']);
        }
        if ($this->has($thyroid, 'hyperthyroidism_remark')) {
            $print[] = $this->fe('thyroid', 'hyperthyroidism_remark', '备注：');
        }

        return $this->getPrintStr('甲状腺情况：患者于', $print);
    }

    public function adrenalGland()
    {
        $thyroid = $this->model->adrenal_gland;

        if (!$thyroid) {
            return null;
        }
        $print = [];
        if ($this->has($thyroid, 'started_at')) {
            $print[] = $this->fe('adrenal_gland', 'started_at', '起病日期:');
        }

        if ($this->has($thyroid,'inducement')) {
            $print[] = $this->ft('hpi.inducement', $this->fe('adrenal_gland', 'inducement'), '诱因:');
        }

        if ($this->has($thyroid, 'symptoms')) {
            $print[] = '起病症状：' . implode('、', $thyroid['symptoms']);
        }
        if ($this->has($thyroid, 'symptoms_remark')) {
            $print[] = $this->fe('adrenal_gland', 'symptoms_remark', '备注：');
        }

        if ($this->has($thyroid, 'accompanied_symptom')) {
            $print[] = '伴随症状：' . implode('、', $thyroid['accompanied_symptom']);
        }
        if ($this->has($thyroid, 'accompanied_symptom_remark')) {
            $print[] = $this->fe('adrenal_gland', 'accompanied_symptom_remark', '备注：');
        }

        return $this->getPrintStr('高血压肾上腺疾病：患者于', $print);
    }
}